/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package heureCalcul.interfaceGraphique;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author Alex
 */
public class HeureCalculFrame extends JFrame {

    private JTextField heureBaseField = new JTextField("0h00");
    //private DateFormatUtil heureBaseDate;

    private JTextField heureModifField = new JTextField("0h00");
    //private DateFormatUtil heureBaseModif;

    private JButton ajouter = new JButton("+");
    private JButton soustraire = new JButton("-");

    public HeureCalculFrame(String nomFenetre)
    {
        super(nomFenetre);

        Container fenetre = getContentPane();

        JPanel panel = new JPanel(new GridLayout(1, 3, 20, 20));

        JPanel pBoutons = new JPanel(new GridLayout(2, 1, 20, 20));

        Font police = new Font("Arial", Font.BOLD, 35);

        ajouter.addActionListener(new AjouterBouton(this));
        ajouter.setPreferredSize(new Dimension(10, 10));
        ajouter.setFont(police);
        pBoutons.add(ajouter);

        soustraire.addActionListener(new SoustraireBouton(this));
        soustraire.setPreferredSize(new Dimension(10, 10));
        soustraire.setFont(police);
        pBoutons.add(soustraire);

        heureBaseField.setFont(police);
        heureModifField.setFont(police);
        heureBaseField.setHorizontalAlignment(JTextField.CENTER);
        heureModifField.setHorizontalAlignment(JTextField.CENTER);
        
        panel.add(heureBaseField, BorderLayout.WEST);
        panel.add(pBoutons, BorderLayout.CENTER);
        panel.add(heureModifField, BorderLayout.EAST);

        fenetre.add(panel);        
        
    }

    public static void run(JFrame frame, int width, int height)
    {
        //Centrage
        //setLocationRelativeTo(null); //centrer
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int X = (screen.width / 2) - (width / 2); // Center horizontally.
        int Y = (screen.height / 2) - (height / 2); // Center vertically.

        frame.setBounds(X, Y, width, height);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(width, height);
        frame.setVisible(true);
    }


    public void setHeureBaseField(JTextField heureBaseField) {
        this.heureBaseField = heureBaseField;
    }

    public void setHeureModifField(JTextField heureModifField) {
        this.heureModifField = heureModifField;
    }

    public JTextField getHeureBaseField() {
        return heureBaseField;
    }

    public JTextField getHeureModifField() {
        return heureModifField;
    }


}
